# 第 2 章 变量和简单数据类型
print("Hello Python world!")
# 2.2变量
message="hello zzp"
print(message)
# 变量修改
message="hello xm"
print(message)

# 2.3 字符串
name="herman zzp"
print(name)
# 2.3.1 使用方法修改字符串的大小写
# title() 以首字母大写的方式显示每个单词
print(name.title())
print(name.upper())
print(name.lower())

# 2.3.2 合并（拼接）字符串
first_name="herman"
last_name="zzp"
full_name=first_name+" "+last_name
print("hello, "+full_name+"!")

# 2.3.3 使用制表符或换行符来添加空白
print("zzp")
print("\tzzp")
print("herman\nzzp")
print("herman\n\tzzp")

# 2.3.4 删除空白
# 结尾
favorite_language = 'python '
print(favorite_language)
print(favorite_language.rstrip())
print(favorite_language)
favorite_language=favorite_language.rstrip()
print(favorite_language)

# 开头
favorite_language1 = ' herman'
print(favorite_language1)
print(favorite_language1.lstrip())
print(favorite_language1)
favorite_language1=favorite_language1.lstrip()
print(favorite_language1)

# 两边
favorite_language2 = ' python '
print(favorite_language2)
print(favorite_language2.strip())
print(favorite_language2)
favorite_language2=favorite_language2.strip()
print(favorite_language2)

# 2.3.5 使用字符串时避免语法错误
message="herman'zzp"
print(message)
# 免语法错误
# message='herman'zzp'
# print(message)

# 2.4 数字
# 2.4.1 整数
print(2+3)
print(3+2)
print(2*3)
print(3/2)
# 乘方
print(2**3)
# 运算次序
print(2+3*5)
print((2+3)*5)
# 2.4.2 浮点数
print(0.1+0.1)
print(2+0.1)
print(0.2+0.1)
# 2.4.3 使用函数str() 避免类型错误
age=28
message="happy "+str(age)+"rd Birthday"
print(message)
print(3/2)
print()